<?php require_once(dirname(__FILE__) . '/inc/config.inc.php');
IsModelPriv('order'); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>用户列表</title>
    <link href="templates/style/admin.css" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" src="templates/js/jquery.min.js"></script>
    <script type="text/javascript" src="layer/layer.js"></script>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="ui/css/bootstrap.min.css">
    <link rel="stylesheet" href="ui/css/bootstrap-theme.min.css">
    <!-- 最新版本的 layui 核心 CSS 文件 -->

    <link href="layui/css/layui.css" rel="stylesheet" type="text/css" media="all"/>
    <script src="layui/layui.all.js"></script>
    <script type="text/javascript">

        function userSyncAll(id) {
            $.get('/wx/userSyncALL.php');
            layer.alert('后台数据同步中，请稍等查看', {
                skin: 'layui-layer-molv' //样式类名
            });

        }

    </script>
</head>
<body>
<style>
    .layui-table-cell { /*最后的pic为字段的field*/
        height: 100%;
        max-width: 100%;
        height: auto;
        white-space: normal;
        word-wrap: break-word;
        word-break: break-all;
    }
    .layui-layout-body {
        overflow: auto;
    }
    .mt10 { margin-top: 10px;}
</style>
<div class="">
    <div class="">
        <div class="layui-fluid">
            <div class="layui-row">
                <!-- 右表 -->
                <div class="layui-col-sm12 mt10"></div>
                <div class="layui-card layadmin-header">
                    <div class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
                        <a lay-href="">主页</a><span lay-separator="">/</span>
                        <a><cite>用户列表</cite></a><span lay-separator="">/</span>

                    </div>
                </div>
                <div class="layui-col-sm12">

                    <div class="layui-col-sm12 " style="margin-top: 10px;">
                        <div class=" layuiadmin-card-header-auto">
                            <div class="layui-form  layuiadmin-card-header-auto" lay-filter="layadmin-userfront-formlist">
                                <div class="layui-form-item ss">
<!--                                    <div class="layui-inline">-->
<!--                                        <label class="layui-form-label">用户组</label>-->
<!--                                        <div class="layui-input-block">-->
<!--                                            <select name="level" id="level">-->
<!--                                                <option value="0">全部</option>-->
<!--                                                <option value="3">工程师</option>-->
<!--                                                <option value="4">服务站</option>-->
<!--                                                <option value="6">用户</option>-->
<!--                                            </select>-->
<!--                                        </div>-->
<!--                                    </div>-->
                                    <div class="layui-inline">
                                        <label class="layui-form-label">昵称</label>
                                        <div class="layui-input-block">
                                            <input type="text" class="layui-input" name="nickname" id="nickname" autocomplete="off" value="">
                                        </div>
                                    </div>
                                    <div class="layui-inline"><label class="layui-form-label">姓名 ≈</label>
                                        <div class="layui-input-block">
                                            <input type="text" name="truename" id="truename" placeholder="请输入" autocomplete="off" class="layui-input">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">手机号</label>
                                        <div class="layui-input-block">
                                            <input type="text" class="layui-input" name="mobile" id="mobile" autocomplete="off" value="">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">时间</label>
                                        <div class="layui-input-block">
                                            <input type="text" class="layui-input" name="dtime" id="test-laydate-format-range2"
                                                   placeholder="开始 到 结束" autocomplete="off" value="">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <button class="layui-btn layuiadmin-btn-useradmin" lay-submit="" lay-filter="LAY-user-front-search">
                                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i></button>
                                    </div>
                                    <div class="layui-inline">
                                        <button class="layui-btn  layuiadmin-btn-useradmin layui-btn-danger" data-type="refush" lay-tips="重置搜索条件，并显示全部的用户">
                                            全部
                                        </button>
                                    </div>

                                </div>
                            </div>


                        </div>
                    </div>
                    <div class="layui-card">
                        <div class="layui-col-sm12 ">

                            <table id="member" lay-filter="member"></table>
                            <script type="text/html" id="table-pic">
                                {{#  if(d.headimgurl !=""){ }}
                                <img src="{{d.headimgurl}}" width="90" height="90">
                                {{#  } }}
                            </script>
                            <script type="text/html" id="table_status1">
                                {{#  if(d.ispm =="1"){ }}
                                <a class="layui-btn  layui-btn-xs">项目经理</a>
                                {{#  } }}
                                {{#  if(d.isadmin =="1"){ }}
                                <a class="layui-btn layui-btn-danger layui-btn-xs">管理员</a>
                                {{#  } }}
                                {{#  if(d.qiang =="1"){ }}
                                <a class="layui-btn layui-btn-danger layui-btn-xs">可抢单</a>
                                {{#  } }}
                                {{#  if(d.isreport =="1"){ }}
                                <a class="layui-btn layui-btn-warm layui-btn-xs">报表显示</a>
                                {{#  } }}
                            </script>
                            <script type="text/html" id="table_address1">
                                {{d.country}}<br>{{d.province}}<br>{{d.city}}
                            </script>
                            <script type="text/html" id="table_userinfo">
                                单位：{{d.school}}<br>姓名：{{d.truename}}<br>手机：{{d.mobile}}
                            </script>
                            <script type="text/html" id="table_usergroup">
                                {{#  if(d.level =="6"){ }}
                                <button class="layui-btn layui-btn-primary layui-btn-xs">用户</button>
                                {{#  } }}
                                {{#  if(d.level =="4"){ }}
                                <button class="layui-btn layui-btn-success layui-btn-xs">服务站</button>
                                {{#  } }}
                                {{#  if(d.level =="3"){ }}
                                <button class="layui-btn layui-btn-danger layui-btn-xs">工程师</button>
                                {{#  } }}
                            </script>
                            <script type="text/html" id="table-list-op1">
                                <a class="layui-btn layui-btn-success layui-btn-xs" lay-event="edit">
                                    <i class="layui-icon layui-icon-edit"></i>用户管理
                                </a>
                                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="fee">
                                    <i class="layui-icon layui-icon-rmb"></i>奖罚
                                </a>
                            </script>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="">
    layui.config({
        base: 'layui/lay/modules/'
    }).extend({
        admin: 'admin',
        view: 'view'
    }).use(['table', 'admin', 'view','laydate'], function () {

        //无需再执行layui.use()方法加载模块，直接使用即可
        var form = layui.form,
            layer = layui.layer,
            admin = layui.admin,
            view = layui.view,
            laydate = layui.laydate,
            table = layui.table;
        //第一个实例
        table.render({
            elem: '#member'
            , url: 'json/member/list.php?level=3' //数据接口
            , page: true //开启分页
            , cellMinWidth: 100
            , cols:
                [[ //表头
                    {field: 'id', title: 'ID', width: 80}
                    , {title: '头像', align: 'center', toolbar: '#table-pic', width: 120}
                    , {field: 'openid', align: 'center', title: 'openid', width: 120}
                    , {field: 'nickname', align: 'center', title: '昵称'}
                    , {field: 'nickname', align: 'center', title: '用户组', toolbar: '#table_usergroup'}
                    , {align: 'left', title: '微信地区', toolbar: '#table_address1'}
                    , {align: 'left', title: '用户资料', toolbar: '#table_userinfo'}
                    , {field: 'fee',align: 'left', title: '虚拟值',width: 80}

                    , {field: 'addtime', align: 'center', title: '注册时间'}
                    , {field: 'status', title: '权限', toolbar: '#table_status1',width:260}
                    , {field: 'op', title: '操作', toolbar: '#table-list-op1', width: 200}
                ]],
            limit: 6,
            limits: [10, 15, 20, 25, 30],
            text: {none: '暂无数据'}
        });

        form.render(null, 'layadmin-userfront-formlist');


        //监听搜索
        form.on('submit(LAY-user-front-search)', function (data) {
            field = data.field;            //执行重载
            table.reload('member', {
                where: field,
                page: {
                    curr: 1 //重新从第 1 页开始
                }
            });
        });


        //事件
        var active = {
            refush: function () {
                $("#truename").val("");
                $("#mobile").val("");
                $("#nickname").val("");
                $("#test-laydate-format-range2").val("");
                // $("#level").get(0).selectedIndex = 0;
                form.render(null, 'layadmin-userfront-formlist');
                table.reload('member', {
                    where: {
                        'truename': '',
                        'mobile': '',
                        'nickname': '',
                        'dtime': ''
                        // 'level': 0
                    },
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                });
            },

        };
        $('.layui-btn.layuiadmin-btn-useradmin').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });

        //监听工具条
        table.on('tool(member)', function (obj) {
            var data = obj.data;
            console.log(data)
            if (obj.event === 'edit') {
                console.log(data);
                layer.open({
                    type: 2,
                    skin: 'layui-layer-lan', //样式类名
                    title: '编辑用户信息',
                    shadeClose: true,
                    shade: false,
                    maxmin: true, //开启最大化最小化按钮
                    area: ['460px', '690px'],
                    content: 'member_edit.php?id=' + data.id,
                    end: function () {
                        table.reload('member'); //重载表格
                    }
                });
            }
            if (obj.event === 'fee') {
                console.log(data);
                layer.open({
                    type: 2,
                    skin: 'layui-layer-lan', //样式类名
                    title: '奖罚操作',
                    shadeClose: true,
                    shade: false,
                    maxmin: true, //开启最大化最小化按钮
                    area: ['460px', '590px'],
                    content: 'fee_edit.php?id=' + data.id,
                    end: function () {
                        table.reload('member'); //重载表格
                    }
                });
            }
        });

        //获取当前时间
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth() + 1;
        var day = date.getDate();
        if (month < 10) {
            month = "0" + month;
        }
        if (day < 10) {
            day = "0" + day;
        }
        var nowDate = year + "-" + month + "-" + day;
        //日期时间范围
        laydate.render({
            elem: '#test-laydate-format-range2'
            , range: '~'
            , max: nowDate
        });

    });
</script>

</body>
</html>